<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<table>
    <tr><th>Organization</th><th>Campaign</th><th>Start Date</th><th>End Date</th><th>Goal</th><th>Achievement</th></tr>

    <?php foreach ($data as $key => $value) :; ?>
        <tr class="orderRow">
            <td><?php echo $value['org_title']; ?></td>
            <td><a href="javascript:void(0);" id="campaign_<?php echo $key; ?>"><?php echo $value['campaign_title']; ?></a></td>
            <?php
            $start = explode('T', $value['start_time']);
            $end = explode('T', $value['end_time']);
            ?>
            <td><?php echo $start[0]; ?></td>
            <td><?php echo $end[0]; ?></td>
            <td><?php echo '$' . $value['goal']; ?></td>
            <td><?php echo '$' . $value['amount_money']; ?></td>
        </tr>
        <?php foreach ($value['product_list'] as $item) : ?>
            <tr class="productList campaign_<?php echo $key; ?>">
                <td><?php //echo $item->field_firstname_value." ". $item->field_lastname_value;    ?></td>
                <td><?php //echo $item->ttitle;    ?></td>
                <td><?php
                    if ($value['group_by'] == 'Seller') {
                        echo $item->field_firstname_value . " " . $item->field_lastname_value;
                    } elseif ($value['group_by'] == 'Product' || $value['group_by'] == '') {
                        echo $item->title;
                    } elseif ($value['group_by'] == 'Team') {
                        echo $item->ttitle;
                    }
                    ?>
                </td>
                <?php
                if ($value['group_by'] == 'Product') {
                    echo '<td>' . '$' . ($item->cost + $item->price) . '</td>';
                }
                ?>
                <td><?php echo $item->qty; ?></td>
                <td><?php
                    //echo '$'.($item->cost + $item->price)*$item->qty; 
                    echo '$' . number_format($item->totalprice, 2, '.', ',');
                    ?></td>
            </tr>
        <?php endforeach; ?>
    <?php endforeach; ?>
</table>

<?php echo $pager; ?>

